﻿<?xml version="1.0" encoding="utf-8" ?>
<FieldTypes>
  <FieldType>
    <Field Name="TypeName">MediaPlayer</Field>
    <Field Name="ParentType">Text</Field>
    <Field Name="TypeDisplayName">Media Player Field</Field>
    <Field Name="TypeShortDescription">Display a media player in a document library field</Field>
    <Field Name="FieldTypeClass">MediaPlayerFieldType.MediaPlayerField,MediaPlayerFieldType,Version=1.0.0.0,Culture=neutral,PublicKeyToken=1b86441629b3f8f8</Field>
    <PropertySchema>
      <Fields>
        <Field Name="PlayerWidth" DisplayName="Player Width in pixels" Type="Integer">
          <Default>300</Default>
        </Field>
        <Field Name="PlayerHeight" DisplayName="Player Height in pixels" Type="Integer">
          <Default>300</Default>
        </Field>
        <Field Name="PlayerChoice" DisplayName="WMV/AVI Player" Type="Choice">
          <Default>Windows Media Player</Default>
          <CHOICES>
            <CHOICE>Windows Media Player</CHOICE>
            <CHOICE>Silverlight Player</CHOICE>
          </CHOICES>
        </Field>
      </Fields>
    </PropertySchema>
    <RenderPattern Name="DisplayPattern">
      <SetVar Name="VarFieldID">
        <Property Select="ID" />
      </SetVar>
      <SetVar Name="PlayerWidth">
        <ForEach Select="/Fields/Field">
          <IfEqual>
            <Expr1>
              <GetVar Name="VarFieldID"/>
            </Expr1>
            <Expr2>
              <Property Select="ID"/>
            </Expr2>
            <Then>
              <ForEach Select="Customization/ArrayOfProperty">
                <ForEach Select="Property">
                  <Switch>
                    <Expr>
                      <ForEach Select="Name">
                        <Property Select="." />
                      </ForEach>
                    </Expr>
                    <Case Value="PlayerWidth">
                      <ForEach Select="Value">
                        <Property Select="."/>
                      </ForEach>
                    </Case>
                  </Switch>
                </ForEach>
              </ForEach>
            </Then>
          </IfEqual>
        </ForEach>
      </SetVar>
      <SetVar Name="PlayerHeight">
        <ForEach Select="/Fields/Field">
          <IfEqual>
            <Expr1>
              <GetVar Name="VarFieldID"/>
            </Expr1>
            <Expr2>
              <Property Select="ID"/>
            </Expr2>
            <Then>
              <ForEach Select="Customization/ArrayOfProperty">
                <ForEach Select="Property">
                  <Switch>
                    <Expr>
                      <ForEach Select="Name">
                        <Property Select="." />
                      </ForEach>
                    </Expr>
                    <Case Value="PlayerHeight">
                      <ForEach Select="Value">
                        <Property Select="."/>
                      </ForEach>
                    </Case>
                  </Switch>
                </ForEach>
              </ForEach>
            </Then>
          </IfEqual>
        </ForEach>
      </SetVar>
      <SetVar Name="PlayerChoice">
        <ForEach Select="/Fields/Field">
          <IfEqual>
            <Expr1>
              <GetVar Name="VarFieldID"/>
            </Expr1>
            <Expr2>
              <Property Select="ID"/>
            </Expr2>
            <Then>
              <ForEach Select="Customization/ArrayOfProperty">
                <ForEach Select="Property">
                  <Switch>
                    <Expr>
                      <ForEach Select="Name">
                        <Property Select="." />
                      </ForEach>
                    </Expr>
                    <Case Value="PlayerChoice">
                      <ForEach Select="Value">
                        <Property Select="."/>
                      </ForEach>
                    </Case>
                  </Switch>
                </ForEach>
              </ForEach>
            </Then>
          </IfEqual>
        </ForEach>
      </SetVar>
      <SetVar Name="PlayerGuid">
        <GUID/>
      </SetVar>
      <Switch>
        <Expr>
          <Column Name="File_x0020_Type"/>
        </Expr>
        <Case Value="mov">
          <HTML>
            <![CDATA[<object CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="]]>
          </HTML>
          <GetVar Name="PlayerWidth"/>
          <HTML>
            <![CDATA[" height="]]>
          </HTML>
          <GetVar Name="PlayerHeight"/>
          <HTML>
            <![CDATA[" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">
<param name="src" value="/]]>
          </HTML>
          <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
          <HTML>
            <![CDATA[">
<param name="qtsrc" value="/]]>
          </HTML>
          <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
          <HTML>
            <![CDATA[">
<param name="autoplay" value="false">
<param name="loop" value="false">
<param name="controller" value="true">
<embed src="]]>
          </HTML>
          <Column Name="LinkFilename"/>
          <HTML>
            <![CDATA[" qtsrc="/]]>
          </HTML>
          <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
          <HTML>
            <![CDATA[" width="]]>
          </HTML>
          <GetVar Name="PlayerWidth"/>
          <HTML>
            <![CDATA[" height="]]>
          </HTML>
          <GetVar Name="PlayerHeight"/>
          <HTML>
            <![CDATA[" autoplay="true" loop="false" controller="true" pluginspage="http://www.apple.com/quicktime/"></embed>
</object>]]>
          </HTML>
        </Case>
        <Case Value="mpg">
          <HTML>
            <![CDATA[<object CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="]]>
          </HTML>
          <GetVar Name="PlayerWidth"/>
          <HTML>
            <![CDATA[" height="]]>
          </HTML>
          <GetVar Name="PlayerHeight"/>
          <HTML>
            <![CDATA[" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">
<param name="src" value="/]]>
          </HTML>
          <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
          <HTML>
            <![CDATA[">
<param name="qtsrc" value="/]]>
          </HTML>
          <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
          <HTML>
            <![CDATA[">
<param name="autoplay" value="false">
<param name="loop" value="false">
<param name="controller" value="true">
<embed src="]]>
          </HTML>
          <Column Name="LinkFilename"/>
          <HTML>
            <![CDATA[" qtsrc="/]]>
          </HTML>
          <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
          <HTML>
            <![CDATA[" width="]]>
          </HTML>
          <GetVar Name="PlayerWidth"/>
          <HTML>
            <![CDATA[" height="]]>
          </HTML>
          <GetVar Name="PlayerHeight"/>
          <HTML>
            <![CDATA[" autoplay="true" loop="false" controller="true" pluginspage="http://www.apple.com/quicktime/"></embed>
</object>]]>
          </HTML>
        </Case>
        <Case Value="mpeg">
          <HTML>
            <![CDATA[<object CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="]]>
          </HTML>
          <GetVar Name="PlayerWidth"/>
          <HTML>
            <![CDATA[" height="]]>
          </HTML>
          <GetVar Name="PlayerHeight"/>
          <HTML>
            <![CDATA[" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">
<param name="src" value="/]]>
          </HTML>
          <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
          <HTML>
            <![CDATA[">
<param name="qtsrc" value="/]]>
          </HTML>
          <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
          <HTML>
            <![CDATA[">
<param name="autoplay" value="false">
<param name="loop" value="false">
<param name="controller" value="true">
<embed src="]]>
          </HTML>
          <Column Name="LinkFilename"/>
          <HTML>
            <![CDATA[" qtsrc="/]]>
          </HTML>
          <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
          <HTML>
            <![CDATA[" width="]]>
          </HTML>
          <GetVar Name="PlayerWidth"/>
          <HTML>
            <![CDATA[" height="]]>
          </HTML>
          <GetVar Name="PlayerHeight"/>
          <HTML>
            <![CDATA[" autoplay="true" loop="false" controller="true" pluginspage="http://www.apple.com/quicktime/"></embed>
</object>]]>
          </HTML>
        </Case>
        <Case Value="flv">
          <HTML>
            <![CDATA[<div id=']]>
          </HTML>
          <GetVar Name="PlayerGuid"/>
          <HTML>
            <![CDATA['><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div>
<script type="text/javascript" src="/resources/swfobject.js"></script>
<script type="text/javascript">
	var s1 = new SWFObject("/resources/mediaplayer.swf","mediaplayer","]]>
          </HTML>
          <GetVar Name="PlayerWidth"/>
          <HTML>
            <![CDATA[","]]>
          </HTML>
          <GetVar Name="PlayerHeight"/>
          <HTML>
            <![CDATA[","7");
	s1.addParam("allowfullscreen","true");
	s1.addVariable("width","]]>
          </HTML>
          <GetVar Name="PlayerWidth"/>
          <HTML>
            <![CDATA[");
	s1.addVariable("height","]]>
          </HTML>
          <GetVar Name="PlayerHeight"/>
          <HTML>
            <![CDATA[");
	s1.addVariable("file","/]]>
          </HTML>
          <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
          <HTML>
            <![CDATA[");
	s1.addVariable("image","video.jpg");
	s1.write("]]>
          </HTML>
          <GetVar Name="PlayerGuid"/>
          <HTML>
            <![CDATA[");
</script>]]>
          </HTML>
        </Case>
        <Case Value="avi">
          <Switch>
            <Expr>
              <GetVar Name="PlayerChoice"/>
            </Expr>
            <Case Value="Windows Media Player">
              <HTML>
                <![CDATA[<OBJECT id="VIDEO" width="]]>
              </HTML>
              <GetVar Name="PlayerWidth"/>
              <HTML>
                <![CDATA[" height="]]>
              </HTML>
              <GetVar Name="PlayerHeight"/>
              <HTML>
                <![CDATA[" 
	CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">
	<PARAM NAME="URL" VALUE="/]]>
              </HTML>
              <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
              <HTML>
                <![CDATA[">
	<PARAM NAME="SendPlayStateChangeEvents" VALUE="True">
	<PARAM NAME="AutoStart" VALUE="False">
	<PARAM name="uiMode" value="mini">
	<PARAM name="PlayCount" value="9999">
</OBJECT>]]>
              </HTML>
            </Case>
            <Case Value="Silverlight Player">
              <HTML>
                <![CDATA[<script src="/resources/silverlight/MicrosoftAjax.js"></script>
<script src="/resources/silverlight/MicrosoftAjaxWebForms.js"></script>
<script src="/resources/silverlight/SilverlightControl.js"></script>
<script src="/resources/silverlight/SilverlightMedia.js"></script>
<div id=']]>
              </HTML>
              <GetVar Name="PlayerGuid"/>
              <HTML>
                <![CDATA['></div><script type="text/javascript">
//<![CDATA[
Sys.UI.Silverlight.Control.createObject("]]>
              </HTML>
              <GetVar Name="PlayerGuid"/>
              <HTML>
                <![CDATA[", "\u003cobject type=\"application/x-silverlight\" data=\"data:application/x-silverlight,\" id=\"MediaPlayer]]>
              </HTML>
              <GetVar Name="PlayerGuid"/>
              <HTML>
                <![CDATA[\" style=\"height:]]>
              </HTML>
              <GetVar Name="PlayerHeight"/>
              <HTML>
                <![CDATA[;width:]]>
              </HTML>
              <GetVar Name="PlayerWidth"/>
              <HTML>
                <![CDATA[;\"\u003e\r\n\t\u003ca href=\"http://go.microsoft.com/fwlink/?LinkID=108182\"\u003e\u003cimg src=\"http://go.microsoft.com/fwlink/?LinkID=108181\" alt=\"Get Microsoft Silverlight\" style=\"border-width:0;\" /\u003e\u003c/a\u003e\r\n\u003c/object\u003e");
]]>
              </HTML>
              <HTML>//]]</HTML>
              <HTML><![CDATA[>]]></HTML>
              <HTML>
                <![CDATA[</script>
<script type="text/javascript">
//<![CDATA[
Sys.Application.initialize();
Sys.Application.add_init(function() {
    $create(Sys.UI.Silverlight.MediaPlayer, {"autoPlay":false,"mediaSource":"/]]>
              </HTML>
              <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
              <HTML>
                <![CDATA[","scaleMode":1,"source":"/resources/silverlight/player.xml"}, null, null, $get("]]>
              </HTML>
              <GetVar Name="PlayerGuid"/>
              <HTML>
                <![CDATA["));
});
]]>
              </HTML>
              <HTML>//]]</HTML>
              <HTML><![CDATA[>]]></HTML>
              <HTML>
                <![CDATA[</script>]]>
              </HTML>
            </Case>
          </Switch>
        </Case>
        <Case Value="wmv">
          <Switch>
            <Expr>
              <GetVar Name="PlayerChoice"/>
            </Expr>
            <Case Value="Windows Media Player">
              <HTML>
                <![CDATA[<OBJECT id="VIDEO" width="]]>
              </HTML>
              <GetVar Name="PlayerWidth"/>
              <HTML>
                <![CDATA[" height="]]>
              </HTML>
              <GetVar Name="PlayerHeight"/>
              <HTML>
                <![CDATA[" 
	CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">
	<PARAM NAME="URL" VALUE="/]]>
              </HTML>
              <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
              <HTML>
                <![CDATA[">
	<PARAM NAME="SendPlayStateChangeEvents" VALUE="True">
	<PARAM NAME="AutoStart" VALUE="False">
	<PARAM name="uiMode" value="mini">
	<PARAM name="PlayCount" value="9999">
</OBJECT>]]>
              </HTML>
            </Case>
            <Case Value="Silverlight Player">
              <HTML>
                <![CDATA[<script src="/resources/silverlight/MicrosoftAjax.js"></script>
<script src="/resources/silverlight/MicrosoftAjaxWebForms.js"></script>
<script src="/resources/silverlight/SilverlightControl.js"></script>
<script src="/resources/silverlight/SilverlightMedia.js"></script>
<div id=']]>
              </HTML>
              <GetVar Name="PlayerGuid"/>
              <HTML>
                <![CDATA['></div><script type="text/javascript">
//<![CDATA[
Sys.UI.Silverlight.Control.createObject("]]>
              </HTML>
              <GetVar Name="PlayerGuid"/>
              <HTML>
                <![CDATA[", "\u003cobject type=\"application/x-silverlight\" data=\"data:application/x-silverlight,\" id=\"MediaPlayer]]>
              </HTML>
              <GetVar Name="PlayerGuid"/>
              <HTML>
                <![CDATA[\" style=\"height:]]>
              </HTML>
              <GetVar Name="PlayerHeight"/>
              <HTML>
                <![CDATA[;width:]]>
              </HTML>
              <GetVar Name="PlayerWidth"/>
              <HTML>
                <![CDATA[;\"\u003e\r\n\t\u003ca href=\"http://go.microsoft.com/fwlink/?LinkID=108182\"\u003e\u003cimg src=\"http://go.microsoft.com/fwlink/?LinkID=108181\" alt=\"Get Microsoft Silverlight\" style=\"border-width:0;\" /\u003e\u003c/a\u003e\r\n\u003c/object\u003e");
]]>
              </HTML>
              <HTML>//]]</HTML>
              <HTML><![CDATA[>]]></HTML>
              <HTML>
                <![CDATA[</script>
<script type="text/javascript">
//<![CDATA[
Sys.Application.initialize();
Sys.Application.add_init(function() {
    $create(Sys.UI.Silverlight.MediaPlayer, {"autoPlay":false,"mediaSource":"/]]>
              </HTML>
              <LookupColumn Name="FileRef" URLEncodeAsURL="TRUE"/>
              <HTML>
                <![CDATA[","scaleMode":1,"source":"/resources/silverlight/player.xml"}, null, null, $get("]]>
              </HTML>
              <GetVar Name="PlayerGuid"/>
              <HTML>
                <![CDATA["));
});
]]>
              </HTML>
              <HTML>//]]</HTML>
              <HTML><![CDATA[>]]></HTML>
              <HTML>
                <![CDATA[</script>]]>
              </HTML>
            </Case>
          </Switch>
        </Case>
          </Switch>
        </Case>
      </Switch>
    </RenderPattern>
  </FieldType>
</FieldTypes>
